package com.dt76.smallloanbackendservice.service.yaozhao.Impl;

import com.dt76.smallloanbackendservice.mapper.yaozhao.OverDueMapper;
import com.dt76.smallloanbackendservice.pojo.yaozhao.OverDue;
import com.dt76.smallloanbackendservice.service.yaozhao.OverDueService;
import com.dt76.smallloanbackendservice.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OverDueServiceImlp implements OverDueService {

    @Autowired
    private OverDueMapper overDueMapper;
    @Override
    public Page qryPageAll(int pageIndex, String userName, String phoneNumber, String loanId, String ContractId, String riskClassification) {
        Page page = new Page();
        page.setPageIndex(pageIndex);//每次更新当前页
        //更新总条数
        page.setTotalCount(overDueMapper.qryCount(userName,phoneNumber,loanId,ContractId,riskClassification));
        List<OverDue> overDueList = overDueMapper.qryPageAll((page.getPageIndex()-1)*page.getPageSize(),
                page.getPageSize(),userName,phoneNumber,loanId,ContractId,riskClassification);
        page.setRows(overDueList);
        return page;
    }

    @Override
    public Page qryCollectionPageAll(int pageIndex, String userName, String phoneNumber, String loanId, String CollectionType) {
        Page page = new Page();
        page.setPageIndex(pageIndex);//每次更新当前页
        //更新总条数
        page.setTotalCount(overDueMapper.qryCollectionCount(userName,phoneNumber,loanId,CollectionType));
        List<OverDue> overDueList = overDueMapper.qryCollectionPageAll((page.getPageIndex()-1)*page.getPageSize(),
                page.getPageSize(),userName,phoneNumber,loanId,CollectionType);
        page.setRows(overDueList);
        return page;
    }
}
